[#macro restPasswordView]
<div>
    <el-row :gutter="10">
        <el-col :span="20">
            <el-form ref="ruleForm" :model="form" :rules="rules" status-icon label-width="100px" class="demo-ruleForm">
                <el-form-item label="密码" prop="password">
                    <el-input type="password" v-model="form.password" autocomplete="off">
                    </el-input>
                </el-form-item>
                <el-form-item>
                    <el-button @click="resetForm('ruleForm')">重置</el-button>
                    <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
                </el-form-item>
            </el-form>
        </el-col>
    </el-row>

</div>
[/#macro]
[#macro restPasswordConfig]
<script type="text/x-template" id="my-rest-password">
	[@restPasswordView /]
</script>
<script type="text/javascript">
    var restPasswordConfig = {};
    restPasswordConfig.template = "#my-rest-password";
    restPasswordConfig.methods = config.basicMethod();

    restPasswordConfig.methods.submitForm = function (done) {
        var self=this;
        this.$refs["ruleForm"].validate(function (valid) {
            if (valid) {
                self.restPassword();
            } else {
                console.log('error submit!!');
                return false;
            }
        });
    }
    restPasswordConfig.methods.resetForm = function (event) {
        this.$refs['ruleForm'].resetFields()
    }

    

    restPasswordConfig.methods.restPassword = function (done) {
       var self=this;
       var params=this.form;
       this.postData("${siteurl}tenantRest/userinfo/restPassword.htm", params, function (res) {
            if (res.code == 0) {
                self.$message({
                    message: '重置密码成功',
                    type: 'success'
                });
            } else {
                self.$message.error(res.msg);
            }
        });

    }

    restPasswordConfig.computed = {};
    restPasswordConfig.computed.classInfoOptions = function () {
        return this.$store.state.classInfoOptions;
    };
    restPasswordConfig.computed.schoolOptions = function () {
        return this.$store.state.schoolOptions;
    };

    restPasswordConfig.data = function () {
        return {
            form: {
                id: "",
                password: ""
            },
            dialogVisible: false,
            defaultProps: {
                children: 'children',
                label: 'name'
            },
            loading: false,
            rules: {
                password: [
                    { required: true, message: '请输入密码', trigger: 'blur' }
                ],
            }
        }
    };
    restPasswordConfig.mounted = function () {
        var id = this.$route.query.id;
        var self = this;
        self.form.id = id;
    }
    var restPasswordView = Vue.component('my-rest-password', restPasswordConfig);
</script>
[/#macro]